﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataLib.Accounts.Bus;
using System.Data;

namespace Ewts.Storage
{
    public partial class PDNoAdd : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {

                if (Session["UserInfo"] != null)
                {
                    User curUser = new DataLib.Accounts.Bus.User();
                    curUser = (User)Session["UserInfo"];
                    hidUser.Value = curUser.UserName;
                    string city = "";
                    bindData(city);
                }
                else
                {
                    Response.Redirect("/accounts/login.aspx");
                }
            }
        }

        public void bindData(string city)
        {

            //归属地
            ListItem item = new ListItem();
            item.Text = "--请选择--";
            item.Value = "";
            DataLib.BLL.City bllLib = new DataLib.BLL.City();
            dropBcity.DataSource = bllLib.GetList("flag1='01'");
            dropBcity.DataTextField = "cityname";
            dropBcity.DataValueField = "cityname";
            dropBcity.DataBind();
            dropBcity.Items.Insert(0, item);



            // 处理地
            dropGcity.DataSource = bllLib.GetList("flag1='02'");
            dropGcity.DataTextField = "cityname";
            dropGcity.DataValueField = "cityname";
            dropGcity.DataBind();
            dropGcity.Items.Insert(0, item);


            DataTable dt = new DataTable();
            dt = new DataLib.BLL.InStorage().GetList(" Left(wrlno,1)='R' and cjoid>0 and Left(OutDepart,Len('" + city + "'))='" + city + "'").Tables[0];
            rept.DataSource = dt;
            rept.DataBind();
        } 

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            //DataLib.Model.OutStorage model = new DataLib.Model.OutStorage();
            //DataLib.BLL.OutStorage bll = new DataLib.BLL.OutStorage();
            //if (bll.InsertPDNo(dropBcity.SelectedValue, dropGcity.SelectedValue, hidUser.Value,) > 0)
            //{
            //    DataLib.Common.MessageBox.Show(Page, "添加成功");
            //    bindData("");
            //}
            //else
            //{
            //    DataLib.Common.MessageBox.Show(Page, "添加失败");
            //}

        }
    }
}